var opn = require('opn')
var express = require('express')
var app = express();
var path = require('path')
var proxyMiddleware = require('http-proxy-middleware')

/*var baseUrl = "http://119.23.69.169:8080/interpolation/";
var proxyData = {};
var rqlist    = ["ntq"];
for(var i = 0,len = rqlist.length;i<len;i++){
	var str = rqlist[i];
	var proxypath = str;
	var proxyrewrite = "^"+proxypath;

	proxyData[proxypath] = {
		 target: baseUrl+str,
		 changeOrigin: true,
		 pathRewrite:{}
	};

	proxyData[proxypath].pathRewrite[proxyrewrite] = "";
};

Object.keys(proxyData).forEach(function (context) {
  var options = proxyData[context]
  if (typeof options === 'string') {
    options = { target: options }
  }
  app.use(proxyMiddleware(options.filter || context, options))
})*/

app.use('/ntq', proxyMiddleware({target: 'http://119.23.69.169:8080/interpolation/', changeOrigin: true}));
app.use(express.static(path.resolve(__dirname, "")));

app.listen(9000, function () {
  opn('http://localhost:9000/')
})
